{% extends "layout.html" %}
{% import 'utils.html' as utils %}
{% block title %}New - {{ config.NAME }}{% endblock %}
{% block headers %}
{% endblock %}
{% block content %}
{% include "header.html" %}
{% if thread %}
<div class="content" style="margin-left:10%;margin-right:10%;width:100%">
<div id="notes">
<div class="posts">
<h1 class="content-subhead">Replying to {{ content }}</h1>
{{ utils.display_thread(thread) }}
</div>
</div>
</div>
{% endif %}
<aside style="margin-top:3%;width:80%;margin-bottom:2%">
{% if thread %}
<h3>New reply</h3>
{% else %}
{% if request.args.get("question") == "1" %}
<h3>New question <small><a href="/admin/new" style="color:#FFFFFF">make it a note?</a></small></h3>
{% else %}
<h3>New note <small><a href="/admin/new?question=1" style="color:#FFFFFF">make it a question?</a></small></h3>
{% endif %}
{% endif %}
<form action="/api/new_{% if request.args.get("question") == "1" %}question{%else%}note{%endif%}" method="POST" enctype="multipart/form-data">
<input type="hidden" name="redirect" value="/">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
{% if reply %}<input type="hidden" name="reply" value="{{reply}}">{% endif %}
<p>
{% for emoji in emojis %}
<span class="ji">{{ emoji }}</span>
{% endfor %}
</p>
<textarea name="content" autofocus="autofocus" designMode="on" style="width:100%;height:500px;resize:none">{{ content }}</textarea><br/><br/>
<input type="file" name="file" style="color:#FFFFFF">
{% if request.args.get("question") == "1" %}
<center style="margin-top:20px;">
<p>Open for: <select name="open_for" style="color:#000000">
<option value="30">30 minutes</option>
<option value="60">1 hour</option>
<option value="360">6 hour</option>
<option value="1440" selected>1 day</option>
<option value="4320">3 days</option>
<option value="10080">7 days</option>
</select></p>
<input type="hidden" name="of" value="oneOf" />
<p><select name="of" style="color:#000000">
<option value="oneOf">Single choice</option>
<option value="anyOf">Multiple choices</option>
</select></p>
{% for i in range(4) %}
<p><input type="text" name="answer{{i}}" placeholder="Answer #{{i+1}}"></p>
{% endfor %}
</center>
{% endif %}
<input type="submit" value="Post" class="pure-button pure-button-success" style="float:right">
</div>
</form>
</aside>
<script>
var ta = document.getElementsByTagName("textarea")[0];
function insertAtCursor (textToInsert) {
ta.focus();
const isSuccess = document.execCommand("insertText", false, textToInsert);
if (!isSuccess) {
const value = ta.value;
const start = ta.selectionStart;
const end = ta.selectionEnd;
ta.value = value.slice(0, start) + textToInsert + value.slice(end);
ta.selectionStart = ta.selectionEnd = start + textToInsert.length;
}
}
var ji = function (ev) {
insertAtCursor(ev.target.attributes.alt.value + " ");
ta.focus()
}
var items = document.getElementsByClassName("ji")
for (var i = 0; i < items.length; i++) {
items[i].addEventListener('click', ji);
}
</script>{% endblock %}
